package com.cn.qtms.dao;//类注释设置模板

import com.cn.qtms.base.dao.BaseDao;
import com.cn.qtms.entity.TmSysUser;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @Name:TmSysUserDao
 * @Description:
 * @Author: zhangyang
 * @Date 2019-11-11 13:14
 **/
@Repository
public interface TmSysUserDao extends BaseDao<TmSysUser,Long> {
    /**
     * 通过用户名获取用户
     * @param username
     * @return
     */
    @Query(value = "select *  from tm_sys_user where binary username=:username",nativeQuery = true)
    TmSysUser findByUserName(@Param("username") String username);

    /**
     * 通过手机号获取用户
     * @param phone
     * @return
     */
    @Query(value = "select *  from tm_sys_user where  phone=:phone",nativeQuery = true)
    TmSysUser findByPhone(@Param("phone") String phone);

    /**
     * 修改用户密码
     * @param username
     * @param password
     */
    @Modifying
    @Query(value = "update tm_sys_user set password=:password where  username=:username", nativeQuery = true)
    public void updatePwd(@Param("username") String username, @Param("password") String password);
}
